/*
 * Copyright 2009 Tony Ganchev
 * 
 * This file is part of oneBricks.
 * 
 * oneBricks is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * oneBricks is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with oneBricks.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.onebricks;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Servlet extends HttpServlet {
	public Servlet() {
		LOG.debug(this.toString());
		LOG.info("Servlet created.");
	}

	protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException,
			IOException {
		LOG.info("Received request.");
		LOG.debug(req.toString());

		final PrintWriter out = resp.getWriter();

		out.println("<html><body>");
		out.println("<form><input type=\"text\" name=\"qmkss\" />");
		out.println("<input type=\"submit\" value=\"Go!\" /></form>");
		final String qmkss = req.getParameter("qmkss");
		if (qmkss != null) {
			out.println("<br />qmkss = " + qmkss);
		}
		out.println("</body></html>");

		LOG.info("Request handled successfully.");
	}

	public String toString() {
		return super.toString();
	}

	private static final Logger LOG = LoggerFactory.getLogger(Servlet.class);
	private static final long serialVersionUID = -4358798506750284272L;

}
